<%--
  Created by IntelliJ IDEA.
  User: 陶昱全
  Date: 2021/12/11
  Time: 11:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>作业管理系统</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

    <link rel="stylesheet" type="text/css" href="../static/css/teacherSystem.css"/>

</head>
<body>
<div class="container-fluid">
    <div class="container con1">
        <div class="row rown">
            <div class="col-md-10">
                <div class="col-md-12">
                    <img src="../static/img/16353973302582117.png" class="img-rounded" />
                    <h1>
                        <span>作业管理系统</span>
                    </h1>
                </div>
            </div>
            <div class="col-md-2">
                <div class="col-md-12">
                    <a  class="btn woff" href="${pageContext.request.contextPath}/hms/teaLogout">注销</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="row" id="from">
                <div class="col-md-12">

                </div>
            </div>
            <div class="row row-block">
                <div class="col-md-12" id="a2">
                    <blockquote>
                        <p>
                            教师管理
                        </p>
                    </blockquote>
                    <div class="btn-group">

                        <button class="btn" type="button"><em class="icon-align-left"><a id="modal-12" href="#modal-container-12" role="button" class="btn" data-toggle="modal">添加教师</a></em></button>
                        <div id="modal-container-12" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                        <h3 id="myModalLabel">
                                            添加新教师
                                        </h3>
                                    </div>
                                    <div class="modal-body">
                                        <form id="addForm" action="${pageContext.request.contextPath}/hms/addTeacher" method="post">
                                            <input type="text" name="id" placeholder="请输入教工号" />
                                            <input type="text" name="name" placeholder="姓名"/>
                                            <input type="text" name="password" placeholder="初始密码"/>
                                        </form>
                                    </div>
                                    <div class="modal-footer">
                                        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                                        <button class="btn btn-primary" type="button" id="submitAdd" data-dismiss="modal"  aria-hidden="true">确认</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <br />
                    <br />
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>
                                教工号
                            </th>
                            <th>
                                姓名
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="teacher" items="${requestScope.get('teacher')}">
                            <tr class="warning">
                                <td>${teacher.id}</td>
                                <td>${teacher.name}</td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    $("#submitAdd").click(function(){

        let targetUrl = $("#addForm").attr("action");
        let data = $("#addForm").serialize();
        $.ajax({
            type:'post',
            url:targetUrl,
            cache: false,
            data:data,  //重点必须为一个变量如：data
            dataType:'json',
        })

    })
</script>
</html>
